/**
 * 生成成功响应
 */
export interface SuccessResponse<T = any> {
    code: number;
    message: string;
    data: T;
    timestamp: number;
    success: boolean;
  }
  
  /**
   * 生成失败响应
   */
  export interface ErrorResponse {
    code: number;
    message: string;
    data: any;
    timestamp: number;
    success: boolean;
  }
  
  export const successResponse = <T = any>(
    data: T = null as any,
    message: string = '操作成功',
    code: number = 200
  ): SuccessResponse<T> => {
    return {
      code,
      message,
      data,
      timestamp: new Date().getTime(),
      success: true
    };
  };
  
  export const errorResponse = (
    message: string = '操作失败',
    code: number = 500,
    data: any = null
  ): ErrorResponse => {
    return {
      code,
      message,
      data,
      timestamp: new Date().getTime(),
      success: false
    };
  };
  
  export const pageResponse = <T = any>(
    list: T[],
    total: number,
    pagination: { current?: number; pageSize?: number }
  ) => {
    return successResponse({
      list,
      pagination: {
        current: pagination.current || 1,
        pageSize: pagination.pageSize || 10,
        total,
        totalPages: Math.ceil(total / (pagination.pageSize || 10))
      }
    });
  };